package com.msb.mall.thirdPart.enums;

import com.msb.mall.thirdPart.constants.UploadConstants;
import org.apache.commons.lang.StringUtils;

/**
 * TODO
 *
 * @author xulei
 * @date 2024/5/17 10:25
 */
public enum UploadPathServerEnum {

    UPLOAD_USE_COMMON(UploadConstants.UPLOAD_TYPE_COMMON, UploadConstants.UPLOAD_USE_PATH_COMMON, UploadConstants.UPLOAD_NOUSE_PATH_COMMON),
    UPLOAD_USE_PRODUCT(UploadConstants.UPLOAD_TYPE_PRODUCT, UploadConstants.UPLOAD_USE_PATH_PRODUCT, UploadConstants.UPLOAD_NOUSE_PATH_PRODUCT),
    UPLOAD_USE_ORDER(UploadConstants.UPLOAD_TYPE_ORDER, UploadConstants.UPLOAD_USE_PATH_ORDER, UploadConstants.UPLOAD_NOUSE_PATH_ORDER),
    UPLOAD_USE_COUPON(UploadConstants.UPLOAD_TYPE_COUPON, UploadConstants.UPLOAD_USE_PATH_COUPON, UploadConstants.UPLOAD_NOUSE_PATH_COUPON),
    UPLOAD_USE_WARE(UploadConstants.UPLOAD_TYPE_WARE, UploadConstants.UPLOAD_USE_PATH_WARE, UploadConstants.UPLOAD_NOUSE_PATH_WARE),
    UPLOAD_USE_MEMBER(UploadConstants.UPLOAD_TYPE_MEMBER, UploadConstants.UPLOAD_USE_PATH_MEMBER, UploadConstants.UPLOAD_NOUSE_PATH_MEMBER),
    ;


    private String type;
    private String usePath;
    private String noUsePath;

    UploadPathServerEnum(String type, String usePath, String noUsePath) {
        this.type = type;
        this.usePath = usePath;
        this.noUsePath = noUsePath;
    }

    public static String getUsePath(String type) {
        String usePath = UPLOAD_USE_COMMON.usePath;
        if(StringUtils.isEmpty(type)) {
            return usePath;
        }

        switch (type) {
            case UploadConstants.UPLOAD_TYPE_PRODUCT:
                usePath = UPLOAD_USE_PRODUCT.usePath; break;
            case UploadConstants.UPLOAD_TYPE_ORDER:
                usePath = UPLOAD_USE_ORDER.usePath; break;
            case UploadConstants.UPLOAD_TYPE_COUPON:
                usePath = UPLOAD_USE_COUPON.usePath; break;
            case UploadConstants.UPLOAD_TYPE_MEMBER:
                usePath = UPLOAD_USE_MEMBER.usePath; break;
            case UploadConstants.UPLOAD_TYPE_WARE:
                usePath = UPLOAD_USE_WARE.usePath; break;
            default:;
        }

        return usePath;
    }

    public static String getNoUsePath(String type) {
        String noUsePath = UPLOAD_USE_COMMON.noUsePath;
        if(StringUtils.isEmpty(type)) {
            return noUsePath;
        }

        switch (type) {
            case UploadConstants.UPLOAD_TYPE_PRODUCT:
                noUsePath = UPLOAD_USE_PRODUCT.noUsePath; break;
            case UploadConstants.UPLOAD_TYPE_ORDER:
                noUsePath = UPLOAD_USE_ORDER.noUsePath; break;
            case UploadConstants.UPLOAD_TYPE_COUPON:
                noUsePath = UPLOAD_USE_COUPON.noUsePath; break;
            case UploadConstants.UPLOAD_TYPE_MEMBER:
                noUsePath = UPLOAD_USE_MEMBER.noUsePath; break;
            case UploadConstants.UPLOAD_TYPE_WARE:
                noUsePath = UPLOAD_USE_WARE.noUsePath; break;
            default:;
        }

        return noUsePath;
    }
}
